﻿$(document).on("pageInit", "#time-cource-list4stu", function (e, id, page) {
    loadList();

    function loadList() {
        var week = {
            1: "一",
            2: "二",
            3: "三",
            4: "四",
            5: "五",
            6: "六",
            7: "日"
        };
        $(page).find("#list").empty();
        $.getJSON("/TimeTable/GetCourceList/" + $(page).find('[name="time-table-id"]').val(), {}, function (response) {
            $.each(response, function (index, item) {
                var frame = $('<li class="cource-item" data-project-id="' + item.Id + '">\
                    <div class="item-content">\
                        <div class="item-inner">\
                            <div class="item-title-row">\
                                <div class="item-title">' + item.CourceName + '</div>\
                                <div class="item-after">每周'+ week[item.WeekDay] + " " + item.StartTime + '-' + item.StopTime + '</div>\
                            </div>\
                            <div class="item-subtitle">任课老师：' + item.TeacherName + '</div>\
                            <div class="item-subtitle">地址：' + item.Address + '</div>\
                            <div class="item-text">备注：' + (item.Remark || '') + '</div>\
                        </div>\
                    </div>\
                </li>');
                $(page).find("#list").append(frame);
            });
        });

        $.getJSON('/timetable/GetTimeTableInfo/' + $(page).find('[name="time-table-id"]').val(), function (timetableInfo) {
            console.log(timetableInfo);
            $(page).find(".title").html(timetableInfo.TableName);
        });
    }
});